import { _decorator, Component, ImageAsset, Node, Sprite, SpriteFrame, Texture2D } from 'cc';
const { ccclass, property } = _decorator;

export class Tools {

    static clearFromParent(node: Node, co: any) {
        let arr = [];
        node.children.forEach(element => {
            if (element.getComponent(co)) {
                arr.push(element);
            }
        });
        arr.forEach((element) => {
            element.removeFromParent();
        });

    }

    public static random_between(min: number, max: number): number {
        return Math.random() * (max - min) + min;
    }


    //向下取整，如：min=0,max=10,结果：0，1，2，3，4，5，6，7，8，9
    public static random_between_floor(min: number, max: number): number {
        let ret = Math.random() * (max - min) + min;
        return  Math.floor(ret)
    }
   
}

